package ch04;

/**
 * Created by 其 on 2016/3/20.
 */
public class SearchTest{
    public static void main(String[] args){
        int[] number = {1, 10, 31, 33, 37, 48, 60, 70, 80};
        if(Search.binary(number,1) != 0)
            System.out.println("test failed 1!");
        else if(Search.binary(number,10) != 1)
            System.out.println("test failed 2!");
        else if(Search.binary(number,31) != 2)
            System.out.println("test failed 3!");
        else if(Search.binary(number,33) != 3)
            System.out.println("test failed 4!");
        else if(Search.binary(number,37) != 4)
            System.out.println("test failed 5!");
        else if(Search.binary(number,48) != 5)
            System.out.println("test failed 6!");
        else if(Search.binary(number,60) != 6)
            System.out.println("test failed 7!");
        else if(Search.binary(number,70) != 7)
            System.out.println("test failed 8!");
        else if(Search.binary(number,80) != 8)
            System.out.println("test failed 9!");
        else if(Search.binary(number,0) != -1)
            System.out.println("test failed 10!");
        else if(Search.binary(number,40) != -1)
            System.out.println("test failed 11!");
        else if(Search.binary(number,100) != -1)
            System.out.println("test failed 12!");
        else
            System.out.println("test passed!");
    }
}
